// 这里是写vuex的mutations
import Vue from 'vue'
export default {
    updateCartShopCount(state, {
        dianId,
        shopIndex,
        playload
    }) {
        state.carts[dianId].shops[shopIndex].count = playload
    },
    //删除商品
    delShopCart(state,{dianId,       
         shopIndex
        }){
       state.carts[dianId].shops.splice(0,1)
       for (let i=0;i<state.carts.length;i++){
        if(state.carts[i].shops.length==0){
            state.carts.splice(i,1)
           }
       }
       
    },
    updateCartShopSelect(state, { dianId, shopIndex, playload }) {
        state.carts[dianId].shops[shopIndex].select = playload
    },
    //获取购物车

    UpCarts(state, res) {
        // alert('进入mutation');
        localStorage.setItem("order",JSON.stringify(res)) //本地进行存储
        state.carts = res
        state.order=res
    },
    LOGIN(state,res){
      if(res){
          console.log(res)
        localStorage.setItem("tokens",res) //本地进行存储
        state.token=res
      }else{
        state.token=''
      }
        
    },

}